{"componentChunkName":"component---node-modules-rocketseat-gatsby-theme-docs-core-src-templates-docs-query-js","path":"/code-style/FundsBase-FBE","result":{"data":{"mdx":{"id":"0a0ae418-ba8a-56db-b1d0-c9b32b95f961","excerpt":"FBE-01C: Inefficient Handling of Dispute Resolution Refund Type Severity Location Gas Optimization FundsBase.sol:L253 ,  L254 ,  L258 ,  L274 Description: The…","fields":{"slug":"/code-style/FundsBase-FBE/"},"frontmatter":{"title":"FundsBase Code Style Findings","description":"Contains all the findings that relate to code style on the contract codebase","image":null,"disableTableOfContents":null},"body":"var _excluded = [\"components\"];\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsxRuntime classic */\n\n/* @jsx mdx */\nvar _frontmatter = {\n  \"title\": \"FundsBase Code Style Findings\",\n  \"description\": \"Contains all the findings that relate to code style on the contract codebase\"\n};\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n      props = _objectWithoutProperties(_ref, _excluded);\n\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"h2\", {\n    \"id\": \"span-idfbe-01cfbe-01c-inefficient-handling-of-dispute-resolution-refundspan\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h2\",\n    \"href\": \"#span-idfbe-01cfbe-01c-inefficient-handling-of-dispute-resolution-refundspan\",\n    \"aria-label\": \"span idfbe 01cfbe 01c inefficient handling of dispute resolution refundspan permalink\",\n    \"className\": \"anchor before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), mdx(\"span\", {\n    id: \"FBE-01C\"\n  }, \"FBE-01C: Inefficient Handling of Dispute Resolution Refund\")), mdx(\"table\", null, mdx(\"thead\", {\n    parentName: \"table\"\n  }, mdx(\"tr\", {\n    parentName: \"thead\"\n  }, mdx(\"th\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Type\"), mdx(\"th\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Severity\"), mdx(\"th\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, \"Location\"))), mdx(\"tbody\", {\n    parentName: \"table\"\n  }, mdx(\"tr\", {\n    parentName: \"tbody\"\n  }, mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"/reports/boson-protocol-version-2.5.0-68d13ccd7155940015e05fd3/appendix/finding-types#gas-optimization\"\n  }, \"Gas Optimization\")), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"img\", {\n    parentName: \"td\",\n    \"className\": \"o-severity o-informational\",\n    \"src\": \"https://omniscia.io/report-assets/informational.png\"\n  })), mdx(\"td\", {\n    parentName: \"tr\",\n    \"align\": null\n  }, mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"https://github.com/bosonprotocol/boson-protocol-contracts/blob/6a14c31bead936ed03b2d51ab82010ecd1047f40/contracts/protocol/bases/FundsBase.sol#L253\"\n  }, \"FundsBase.sol:L253\"), \", \", mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"https://github.com/bosonprotocol/boson-protocol-contracts/blob/6a14c31bead936ed03b2d51ab82010ecd1047f40/contracts/protocol/bases/FundsBase.sol#L254\"\n  }, \"L254\"), \", \", mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"https://github.com/bosonprotocol/boson-protocol-contracts/blob/6a14c31bead936ed03b2d51ab82010ecd1047f40/contracts/protocol/bases/FundsBase.sol#L258\"\n  }, \"L258\"), \", \", mdx(\"a\", {\n    parentName: \"td\",\n    \"href\": \"https://github.com/bosonprotocol/boson-protocol-contracts/blob/6a14c31bead936ed03b2d51ab82010ecd1047f40/contracts/protocol/bases/FundsBase.sol#L274\"\n  }, \"L274\"))))), mdx(\"h3\", {\n    \"id\": \"description\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#description\",\n    \"aria-label\": \"description permalink\",\n    \"className\": \"anchor before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Description:\"), mdx(\"p\", null, \"The BPIP-8 has introduced a specialized mutualizer address that is meant to handle dispute resolution fee provisions as well as refunds, and this contract has been integrated by the \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://github.com/bosonprotocol/boson-protocol-contracts/blob/6a14c31bead936ed03b2d51ab82010ecd1047f40/contracts/protocol/bases/FundsBase.sol#L118-L281\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"a\"\n  }, \"FundsBase::releaseFunds\")), \" finalization action.\"), mdx(\"p\", null, \"The current integration appears to be inefficient due to two points; firstly, the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"DisputeResolutionTerms\"), \" data points are read multiple times inefficiently from \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"storage\"), \" whereas they should be loaded to \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"memory\"), \".\"), mdx(\"p\", null, \"Secondly, the current mechanism will either issue a total refund or no refund at all.\"), mdx(\"h3\", {\n    \"id\": \"example\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#example\",\n    \"aria-label\": \"example permalink\",\n    \"className\": \"anchor before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Example:\"), mdx(\"pre\", null, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-sol\",\n    \"metastring\": \"title=contracts/protocol/bases/FundsBase.sol highlight={2,3,7,23} lineNumbers=true lineOffset=251\",\n    \"title\": \"contracts/protocol/bases/FundsBase.sol\",\n    \"highlight\": \"{2,3,7,23}\",\n    \"lineNumbers\": \"true\",\n    \"lineOffset\": \"251\"\n  }, \"// Return unused DR fee to mutualizer or seller's pool\\nif (drTerms.feeAmount != 0) {\\n    uint256 returnAmount = drTerms.feeAmount - payoff.disputeResolver;\\n\\n    // Use exchange-level mutualizer address (locked at commitment time)\\n    if (exchange.mutualizerAddress == address(0)) {\\n        if (returnAmount > 0) {\\n            increaseAvailableFundsAndEmitEvent(\\n                _exchangeId,\\n                offer.sellerId,\\n                exchangeToken,\\n                returnAmount,\\n                sender\\n            );\\n        }\\n    } else {\\n        if (exchangeToken == address(0)) {\\n            IDRFeeMutualizer(exchange.mutualizerAddress).returnDRFee{ value: returnAmount }(\\n                _exchangeId,\\n                returnAmount\\n            );\\n        } else {\\n            if (returnAmount > 0) {\\n                IERC20(exchangeToken).safeApprove(exchange.mutualizerAddress, returnAmount);\\n            }\\n            IDRFeeMutualizer(exchange.mutualizerAddress).returnDRFee(_exchangeId, returnAmount);\\n        }\\n    }\\n}\\n\")), mdx(\"h3\", {\n    \"id\": \"recommendation\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#recommendation\",\n    \"aria-label\": \"recommendation permalink\",\n    \"className\": \"anchor before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Recommendation:\"), mdx(\"p\", null, \"We advise the code to be optimized by loading data into \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"memory\"), \" and by optimizing the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"if\"), \" conditional that triggers the refund to \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"drTerms.feeAmount != 0 && payoff.disputeResolver == 0\"), \", permitting the code within to omit several conditionals.\"), mdx(\"h3\", {\n    \"id\": \"alleviation-efd5d1a8f23c3bca7c25273ea4c912a367250119\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", {\n    parentName: \"h3\",\n    \"href\": \"#alleviation-efd5d1a8f23c3bca7c25273ea4c912a367250119\",\n    \"aria-label\": \"alleviation efd5d1a8f23c3bca7c25273ea4c912a367250119 permalink\",\n    \"className\": \"anchor before\"\n  }, mdx(\"svg\", {\n    parentName: \"a\",\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }, mdx(\"path\", {\n    parentName: \"svg\",\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  }))), \"Alleviation (efd5d1a8f23c3bca7c25273ea4c912a367250119):\"), mdx(\"p\", null, \"The exhibit was partly addressed by introducing the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"memory\"), \" related optimization, however, the Boson Protocol team clarified that zero-value exchange finalizations on the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"IDRFeeMutualizer\"), \" should occur to ensure it is informed that no fee was ultimately captured.\"), mdx(\"p\", null, \"As such, we consider this exhibit fully addressed.\"), mdx(ViewDiffButton, {\n    repoUrl: \"https://github.com/bosonprotocol/boson-protocol-contracts\",\n    mainHash: \"6a14c31bead936ed03b2d51ab82010ecd1047f40\",\n    fixHash: \"efd5d1a8f23c3bca7c25273ea4c912a367250119\",\n    gitHubIssue: \"1059\",\n    mdxType: \"ViewDiffButton\"\n  }));\n}\n;\nMDXContent.isMDXComponent = true;","headings":[{"depth":2,"value":"<span id=\"FBE-01C\">FBE-01C: Inefficient Handling of Dispute Resolution Refund</span>"},{"depth":3,"value":"Description:"},{"depth":3,"value":"Example:"},{"depth":3,"value":"Recommendation:"},{"depth":3,"value":"Alleviation (efd5d1a8f23c3bca7c25273ea4c912a367250119):"}]}},"pageContext":{"slug":"/code-style/FundsBase-FBE/","prev":{"label":"ExchangeCommitFacet.sol (ECF-C)","link":"/code-style/ExchangeCommitFacet-ECF"},"next":{"label":"OfferBase.sol (OBE-C)","link":"/code-style/OfferBase-OBE"}}},"staticQueryHashes":["1954253342","2328931024","2501019404","973074209"]}